#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef enum {true,false} bool;

static int weigth[17] = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2};

static char search[11] = {'1','0','X','9','8','7','6','5','4','3','2'};


bool validateNumber(const char* number);



int main(void){
    
    int N;
    scanf("%d",&N);
    char* s[N];
    int i;
    for (i = 0; i < N; i++) {
        s[i] = (char*)malloc(sizeof(char) * 18);
        scanf("%s",s[i]);
    }
    int j;
    int sum =0;
    for (j = 0; j < N; j++) {
        if(validateNumber(s[j]) == false){
            printf("%s\n",s[j]);
            sum++;
        }
    }
    if(sum == 0){
        printf("All passed\n");
    }
    return 0;
}

bool validateNumber(const char* number){
    if(number == NULL){
        return false;
    }
    int len  = strlen(number);
    if(len != 18){
        return false;
    }
    int sum = 0;
    int i;
    for (i = 0; i < 17; i++) {
        sum += (number[i] - '0') * weigth[i];
    }
    int finalNumber = sum % 11;
    char c = number[17];
    char s = search[finalNumber];
    if(c == s){
        return true;
    } else{
        return false;
    }

}

